package org.jeecg.modules.submodules.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.submodules.entity.Time;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;

/**
 * @Description: 时间记录
 * @Author: jeecg-boot
 * @Date:   2020-07-17
 * @Version: V1.0
 */
@Repository
public interface TimeMapper extends BaseMapper<Time> {

    @Select("select\n" +
            "time.id\n" +
            "from\n" +
            "time\n" +
            "left join big_orders_time bot on bot.TIME_ID = time.id\n" +
            "left join orders o on o.id = bot.ORDERS_ID\n" +
            "left join orders_connect oc on oc.ORDERS_ID = o.id\n" +
            "left join big_orders bo on bo.id = oc.BIG_ORDERS_ID\n" +
            "\n" +
            "where \n" +
            "bo.id = #{id}")
    List<String> getTimeIdByBigOrdersId(@Param("id") String bigOrdersId);

    @Select("select\n" +
            "t.id\n" +
            "from\n" +
            "time t\n" +
            "left join big_orders_time bot on bot.TIME_ID = t.ID\n" +
            "left join orders o on o.id = bot.ORDERS_ID\n" +
            "left join orders_connect oc on oc.ORDERS_ID = o.id\n" +
            "left join big_orders bo on bo.id = oc.BIG_ORDERS_ID\n" +
            "left join orders_end oe on oe.ORDERS_ID = o.id\n" +
            "left join sys_depart sd on sd.id = oe.END_ID\n" +
            "where bo.ID = #{id}\n" +
            "AND( t.ARRIVE_TIME is null\n" +
            "or t.UNLOADING_TIME is null)\n" +
            "\n")
    List<String> checkNullTime(@Param("id") String bigOrdersId);

}
